/*
 * Albareth - an action roleplaying game.
 * Copyright (C) 2008 Jens Anuth
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 *  02110-1301, USA.
 * 
 * $Id: Food.java 43 2008-05-13 16:52:12Z jens464 $
*/
package albareth.core.entity.item;

import albareth.core.action.Action;
import albareth.core.buff.BuffHealOverTime;
import albareth.core.entity.ActionItem;
import albareth.core.entity.Mobile;
import albareth.frontend.Resources;
import albareth.frontend.Tile;
import albareth.frontend.TileCollection;

public class Food extends ActionItem implements Cloneable
{
    private int _hitsPerTick;
    private int _ticks = 20;
    private int _tickPeriod = 10000;

    
    public Food(String name, Tile tile,
            int hitsPerTick, int ticks, int tickPeriod)
    {
        super(name, tile);
        _hitsPerTick = hitsPerTick;
        _ticks = ticks;
        _tickPeriod = tickPeriod;

        Action foodAction = new Action("Eating")
        {
            protected boolean onInitiate(Mobile src)
            {
                return true;
            }

            protected boolean onExecute(Mobile src)
            {
                return src.tryBuff(
                        new BuffHealOverTime(
                                "Food Regeneration",
                                TileCollection.ICON_STRAWBERRY,
                                _hitsPerTick, _tickPeriod, _ticks
                        )
                );
            }
        };
        foodAction.setCastingDuration(3500);
        //foodAction.setCooldownGroup(Mobile.COOLDOWN_GROUP_FOOD);
        setAction(foodAction);
    }
    
    public Object clone() throws CloneNotSupportedException
    {
        return super.clone(); 
    }

    public boolean onActivate(Mobile src)
    {
        Action action = getAction();
        if (src.tryAction(action)) {
            src.eventMsg("You start eating " + getName() + ".");
            src.emitSound(Resources.SOUND_EATING);
            consume();
            return true;
        }
        return false;
    }

    public void enchant(int level)
    {
        // TODO Auto-generated method stub
        
    }

}
